#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>

#define FILENAME "log.txt"

int main()
{
    FILE* fp = fopen(FILENAME, "w");
    if(fp == NULL)
    {
        perror("fopen");
        return 1;
    }
    
    const char* msg = "hello world\n";
    int cnt = 5;
    while(cnt)
    {
        int n = fwrite(msg, strlen(msg), 1, fp);
        printf("write: %d block, pid is : %d\n",n, getpid());
        cnt--;
    }

    fclose(fp);
    return 0;
}
